<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 *
 * @package  	PyroCMS
 * @subpackage  Categories
 * @category  	Module
 * @author  	PyroCMS Dev Team
 */
class Admin_Myservice extends Admin_Controller {

	/**
	 * The current active section
	 * @access protected
	 * @var int
	 */
	protected $section = 'escort-myservice';
	protected $_ci;
	/**
	 * The constructor
	 * @access public
	 * @return void
	 */
	public function __construct()
	{
		parent::__construct();
		
		$this->_ci = &get_instance();
		$this->lang->load('be_escort');
		$this->lang->load('be_escort_myservice');
	}
	
	/**
	 * Index method, lists all categories
	 * @access public
	 * @return void
	 */
	public function index($id)
	{
		$id OR redirect('admin/be_escort');
		
		$escort = $this->_ci->escort_entity->init('id', $id);
		$user = $this->_ci->user_entity->init('id', $escort->getUserId());
		$lockedEscort = $this->_ci->locked_escort_entity->init('escort_id', $id);
		if(!$lockedEscort){
			$this->_ci->locked_escort_entity->createNewLockedEscortEntity($id);
			$lockedEscort = $this->_ci->locked_escort_entity->init('escort_id', $id);
		}
		
		if(!$escort || !$user){
			die();
		}
		$this->data['escort'] = $escort;
		$this->data['user'] = $user;
		$this->data['lockedEscort'] = $lockedEscort;
		$this->pyrocache->delete_all('modules_m');
		$this->load->view('admin/myservices/index', $this->data);
	}
	public function save(){
		
	}
	public function calNetAmount(){
		$escortId = $this->input->post('escort_id');
		//$USER = getAccountUserObject();
		//$ESCORT = $this->escort_entity->init('user_id',$USER->getId());

		$ESCORT = $this->_ci->escort_entity->init('id',$escortId);
		$USER = $this->_ci->user_entity->init('id', $ESCORT->getUserId());
		
		$period = intval($_POST['period']);
		$subscription_id = intval($_POST['subscription_id']);
		$list_place_array = array_filter( explode(',',$_POST['list_place']) );
		$list_pack_array = array_filter( explode(',',$_POST['list_pack']) );
		$list_priority_array = array_filter( explode(',',$_POST['list_priority']) );
		$promocode = $_POST['promocode'];
		
		$discount_contract = contractDiscount_ioc($period); 
		
		$DISCOUNT= $this->discount_ticket_entity->getDiscountEscortByPromotionCode($promocode,$ESCORT->getId());
		if($DISCOUNT){
			$amount = $DISCOUNT->amount;
			switch($DISCOUNT->unit){
				case 'month':
					$unit = 'MONTH';
					break;
				case '%':
					$unit = 'PERCENT';
					break;
				default:
					$unit = 'EURO';
					break;
			}
			$info = $DISCOUNT->name;
			$promo_code = $promocode;
		}else{
			$amount = 0;
			$unit = '';
			$info = '';
			$promo_code = '';
		}
 
		$old_subscription_id = $this->payment_log_entity->getServicesTypePaid($ESCORT->getId(), 'SUBS');
		$old_PlaceListArray = array_filter( explode(',', $this->payment_log_entity->getServicesTypePaid($ESCORT->getId(), 'PLACE')) );
		$old_PackListArray = array_filter( explode(',', $this->payment_log_entity->getServicesTypePaid($ESCORT->getId(), 'PACK')) );
		$old_PriorityListArray = array_filter( explode(',', $this->payment_log_entity->getServicesTypePaid($ESCORT->getId(), 'PRI')) );	
		
		$net_amount = $total_price = $total_period_discount = $total_promo_discount = 0;
		$info_array = array();
		
		$subscriptionDataArray = getSubcriptionData_ioc();
		$placesDataArray = getPlaceListWorkData_ioc();
		$packDataArray = getPackListData_ioc();
		$priorityDataArray = getPriorityData_ioc();
		
		////////////////////////////SUBSCRIPTION//////////////////////////////////////////////////////////////////////////
		
		$subsOrgPrice = $subscriptionDataArray[$subscription_id][1];
		$subsprice = $subsOrgPrice*$period*( 1- $discount_contract/100 ) ;
		$subsPeriodDiscountPrice = $subsOrgPrice*$period*$discount_contract/100;
		$subsPromoDiscountPrice = 0;
		$subsOriginalPrice = $subsOrgPrice*$period;
		
		if($unit == 'PERCENT'){
			$subsPromoDiscountPrice = $subsOriginalPrice*$amount/100;
		}
		if($unit == 'EURO'){
			$subsPromoDiscountPrice = $amount;
		}
		if($unit == 'MONTH'){
			$subsPromoDiscountPrice = $subsOriginalPrice*$amount/$period;			
		}
		
		$subsprice = $subsprice - $subsPromoDiscountPrice;	
		
		if($old_subscription_id){
			$SUB = $this->payment_log_entity->checkServiceExisted($ESCORT->getId(), 'SUBS', $old_subscription_id);
			//$subsprice -= ( $SUB->getNetPrice()/ ($SUB->getPeriod() * 30) ) * ( ( $SUB->getApplyDate() - time() )/86400 );
			$allTimePeriod = $period*PERIOD_TIME + time();
			$subTimeNotUse = $SUB->getApplyDate();
			$subsprice = ( ($allTimePeriod - $subTimeNotUse)/($period*PERIOD_TIME) ) * $subsprice;
		}
		$subsprice = ($subsprice <= 0) ? 0:$subsprice;
		
		$net_amount += $subsprice;
		$total_price += $subsOriginalPrice;
		$total_period_discount += $subsPeriodDiscountPrice;
		$total_promo_discount += $subsPromoDiscountPrice;
		
		$info_array['SUBS'] = array(
										'net_price'=>$subsprice, 'period'=>$period, 
										'discount'=>$discount_contract, 'type_id'=>$subscription_id,
										'period_discount_price'=> $subsPeriodDiscountPrice,
										'promo_discount_price'=> $subsPromoDiscountPrice,
										'payment_price' => $subsOriginalPrice
									);
		
		///////////////////////////LISTING PLACE//////////////////////////////////////////////////////////////////////////
		
		foreach($list_place_array as $item_id){
			$listPlacePeriodDiscountPrice = $listPlacePromoDiscountPrice = 0;
			$listOrgPrice = $placesDataArray[$item_id][1];
			$listprice = $listOrgPrice*$period*( 1 - $discount_contract/100 );
			$listPlacePeriodDiscountPrice = $listOrgPrice*$period*$discount_contract/100;
			$listOriginalPrice = $listOrgPrice*$period;
			
			if($unit == 'PERCENT'){
				$listPlacePromoDiscountPrice = $listOriginalPrice*$amount/100;
			}
			if($unit == 'EURO'){
				$listPlacePromoDiscountPrice = $amount;
			}
			if($unit == 'MONTH'){
				$listPlacePromoDiscountPrice = $listOriginalPrice * $amount/$period;
			}
			
			$listprice = $listprice - $listPlacePromoDiscountPrice;
			
			if( in_array($item_id, $old_PlaceListArray) ){
				$PLACE = $this->payment_log_entity->checkServiceExisted($ESCORT->getId(), 'PLACE', $item_id);
				//$listprice -= ( $PLACE->getNetPrice()/ ($PLACE->getPeriod() * 30) ) * ( ( $PLACE->getApplyDate() - time() )/86400 );
				$allTimePeriod = $period*PERIOD_TIME + time();
				$subTimeNotUse = $PLACE->getApplyDate() ;
				$listprice = ( ($allTimePeriod - $subTimeNotUse)/($period*PERIOD_TIME) ) * $listprice;
			}
			$listprice = ($listprice <= 0) ? 0:$listprice;
			
			$net_amount += $listprice;
			$total_price += $listOriginalPrice;
			$total_period_discount += $listPlacePeriodDiscountPrice;
			$total_promo_discount += $listPlacePromoDiscountPrice;
		
			$info_array['PLACE'][] = array(
							'net_price'=>$listprice, 'period'=>$period, 
							'discount'=>$discount_contract, 'type_id'=>$item_id,
							'period_discount_price'=> $listPlacePeriodDiscountPrice,
							'promo_discount_price'=> $listPlacePromoDiscountPrice,
							'payment_price' => $listOriginalPrice
						);
		}
		
		///////////////////////////PACK//////////////////////////////////////////////////////////////////////////
		
		foreach($list_pack_array as $item_id){
			$packPeriodDiscountPrice = $packPromoDiscountPrice = 0;
			$packOrgPrice = $packDataArray[$item_id][1];
			
			if($packDataArray[$item_id][2] != 1){
				$packprice = $packOrgPrice*$period * ( 1 - $discount_contract/100 ) ;
				$packPeriodDiscountPrice = $packOrgPrice*$period*$discount_contract/100;
				$packOriginalPrice = $packOrgPrice*$period;
			}else{
				if( !$this->payment_log_entity->checkForeverPackage($ESCORT->getUserId(),$item_id) ){
					$packprice = $packOrgPrice;
					$packPeriodDiscountPrice = 0;
					$packOriginalPrice = $packOrgPrice;
				}else{
					$packprice = 0;
					$packPeriodDiscountPrice = 0;
					$packOriginalPrice = 0;
				}
			}
			
			if($unit == 'PERCENT'){
				$packPromoDiscountPrice = $packOriginalPrice*$amount/100;
			}
			if($unit == 'EURO'){
				$packPromoDiscountPrice = $amount; 
			}
			if($unit == 'MONTH'){
				$packPromoDiscountPrice = $packOriginalPrice * $amount/$period; 
			}
			
			$packprice = $packprice - $packPromoDiscountPrice;
			
			if( in_array($item_id, $old_PackListArray) ){
				$PACK = $this->payment_log_entity->checkServiceExisted($ESCORT->getId(), 'PACK', $item_id);
				//check if PACK is apply period or not
				
				//$packprice -= ( $PACK->getNetPrice()/ ($PACK->getPeriod() * 30) ) * ( ( $PACK->getApplyDate() - time() )/86400 );
				//if($packDataArray[$item_id][2] != 1){
					$allTimePeriod = $period*PERIOD_TIME + time();
					$subTimeNotUse = $PACK->getApplyDate();
					$packprice = ( ($allTimePeriod - $subTimeNotUse)/($period*PERIOD_TIME) ) * $packprice;
				//}
			}
			$packprice = ($packprice <= 0) ? 0:$packprice;
			
			$net_amount += $packprice;
			$total_price += $packOriginalPrice;
			$total_period_discount += $packPeriodDiscountPrice;
			$total_promo_discount += $packPromoDiscountPrice;
			
			$info_array['PACK'][] = array(
										'net_price'=>$packprice, 'period'=>$period, 
										'discount'=>$discount_contract, 'type_id'=>$item_id,
										'period_discount_price'=> $packPeriodDiscountPrice,
										'promo_discount_price'=> $packPromoDiscountPrice,
										'payment_price' => $packOriginalPrice
									);
		}
		
		///////////////////////////PRIORITY//////////////////////////////////////////////////////////////////////////
		
		foreach($list_priority_array as $item_id){
			$priPeriodDiscountPrice = $priPromoDiscountPrice = 0;
			$priOrgPrice = $priorityDataArray[$item_id][1];
			$prioprice = $priOrgPrice*$period * ( 1 - $discount_contract/100 );
			$priPeriodDiscountPrice = $priOrgPrice*$period*$discount_contract/100; 
			$priOriginalPrice = $priOrgPrice*$period;
			
			if($unit == 'PERCENT'){
				$priPromoDiscountPrice = $priOriginalPrice*$amount/100;
			}
			if($unit == 'EURO'){
				$priPromoDiscountPrice = $amount;
			}
			if($unit == 'MONTH'){
				$priPromoDiscountPrice = ( $priOriginalPrice * $amount)/$period;
			}
			
			$prioprice = $prioprice - $priPromoDiscountPrice;
			
			if( in_array($item_id, $old_PriorityListArray) ){
				$PRI = $this->payment_log_entity->checkServiceExisted($ESCORT->getId(), 'PRI', $item_id);
				//$prioprice -= ( $PRI->getNetPrice()/ ($PRI->getPeriod() * 30) ) * ( ( $PRI->getApplyDate() - time() )/86400 );
				$allTimePeriod = $period*PERIOD_TIME + time();
				$subTimeNotUse = $PRI->getApplyDate();
				$prioprice = ( ($allTimePeriod - $subTimeNotUse)/($period*PERIOD_TIME) ) * $prioprice;
			}
			$prioprice = ($prioprice <= 0) ? 0:$prioprice;
			
			$net_amount += $prioprice;
			$total_price += $priOriginalPrice;
			$total_period_discount += $priPeriodDiscountPrice;
			$total_promo_discount += $priPromoDiscountPrice;
			
			$info_array['PRI'][] = array(
								'net_price'=>$prioprice, 'period'=>$period, 
								'discount'=>$discount_contract, 'type_id'=>$item_id,
								'period_discount_price'=> $priPeriodDiscountPrice,
								'promo_discount_price'=> $priPromoDiscountPrice,
								'payment_price' => $priOriginalPrice
							);
		}
		$info_array['NET_AMOUNT'] = $net_amount;
		$info_array['DISCOUNT_AMOUNT'] = $amount;
		$info_array['DISCOUNT_UNIT'] = $unit;
		$info_array['DISCOUNT_PROMO_CODE'] = $promo_code;
		$info_array['DISCOUNT_PROMO_INFO'] = $info;
		$info_array['PERIOD_DISCOUNT'] = $discount_contract;
		$info_array['PERIOD'] = $period;
		
		$_SESSION['SERVICES_INFO'] = $info_array;
		
		$current = $total_price - $total_period_discount - $total_promo_discount;
		
		echo json_encode( 
							array(
									'netamount'=>number_format($net_amount,2) , 'totalprice'=> number_format($total_price,2),
									'perioddiscount'=> number_format($total_period_discount,2),
									'promodiscount' => number_format($total_promo_discount,2),
									'currentprice'	=> number_format($current,2)
								) 
						);
		exit();
	
	}
	
	public function load_listing_place_element(){
		$this->load->view('admin/myservices/async_loadListingPlaceElement');
	}
	public function submit_services(){
		//$USER = getAccountUserObject();
		//$ESCORT = $this->escort_entity->init('user_id',$USER->getId());
		
		$escortId = $this->input->post('escort_id');
		$ESCORT = $this->_ci->escort_entity->init('id',$escortId);
		$USER = $this->_ci->user_entity->init('id', $ESCORT->getUserId());
		
		$ESCORT->setOrderControll($this->input->post("order_controll"));
		$ESCORT->adminUpdate();
		
		if(!isset($_SESSION['SERVICES_INFO'])){
			echo 'ok';
			exit;
		} 
		
		$this->db->where('user_id',$USER->getId())->update(TBL_ESCORT_PAYMENT_LOG, array('using_flag'=>'no'));
		if(isset($_SESSION['SERVICES_INFO']['SUBS'])){
			$PL = $this->payment_log_entity->createNewEntity();
			$PL->setEscortId($ESCORT->getId());
			$PL->setUserType('escort');
			$PL->setPayment($_SESSION['SERVICES_INFO']['SUBS']['net_price']);
			$PL->setRegDate(time());
			$PL->setUserId($USER->getId());
			$PL->setPaymentStatus('unpaid');
			$PL->setPeriod($_SESSION['SERVICES_INFO']['SUBS']['period']);
			$PL->setLatestPeriod($_SESSION['SERVICES_INFO']['SUBS']['period']);
			$PL->setDiscount($_SESSION['SERVICES_INFO']['SUBS']['discount']);
			$PL->setServiceType('SUBS');
			$PL->setTypeId($_SESSION['SERVICES_INFO']['SUBS']['type_id']);
			$PL->setPaymentPrice($_SESSION['SERVICES_INFO']['SUBS']['payment_price']);
			$PL->setNetPrice($_SESSION['SERVICES_INFO']['SUBS']['net_price']);
			$PL->setDiscountPeriodPrice($_SESSION['SERVICES_INFO']['SUBS']['period_discount_price']);
			$PL->setDiscountPromoPrice($_SESSION['SERVICES_INFO']['SUBS']['promo_discount_price']);
			
			$PL->update();
		}
		if(isset($_SESSION['SERVICES_INFO']['PLACE'])){
			foreach($_SESSION['SERVICES_INFO']['PLACE'] as $k=>$v){
				$PL = $this->payment_log_entity->createNewEntity();
				$PL->setEscortId($ESCORT->getId());
				$PL->setUserType('escort');
				$PL->setPayment($v['net_price']);
				$PL->setRegDate(time());
				$PL->setUserId($USER->getId());
				$PL->setPaymentStatus('unpaid');
				$PL->setPeriod($v['period']);
				$PL->setLatestPeriod($v['period']);
				$PL->setDiscount($v['discount']);
				$PL->setServiceType('PLACE');
				$PL->setTypeId($v['type_id']);
				$PL->setPaymentPrice($v['payment_price']);
				$PL->setNetPrice($v['net_price']);
				$PL->setDiscountPeriodPrice($v['period_discount_price']);
				$PL->setDiscountPromoPrice($v['promo_discount_price']);
			
				$PL->update();
			}
		}
		if(isset($_SESSION['SERVICES_INFO']['PACK'])){
			foreach($_SESSION['SERVICES_INFO']['PACK'] as $k=>$v){
				$PL = $this->payment_log_entity->createNewEntity();
				$PL->setEscortId($ESCORT->getId());
				$PL->setUserType('escort');
				$PL->setPayment($v['net_price']);
				$PL->setRegDate(time());
				$PL->setUserId($USER->getId());
				$PL->setPaymentStatus('unpaid');
				$PL->setPeriod($v['period']);
				$PL->setLatestPeriod($v['period']);
				$PL->setDiscount($v['discount']);
				$PL->setServiceType('PACK');
				$PL->setTypeId($v['type_id']);
				$PL->setPaymentPrice($v['payment_price']);
				$PL->setNetPrice($v['net_price']);
				$PL->setDiscountPeriodPrice($v['period_discount_price']);
				$PL->setDiscountPromoPrice($v['promo_discount_price']);
				
				$PL->update();
			}
		}
		if(isset($_SESSION['SERVICES_INFO']['PRI'])){
			foreach($_SESSION['SERVICES_INFO']['PRI'] as $k=>$v){
				$PL = $this->payment_log_entity->createNewEntity();
				$PL->setEscortId($ESCORT->getId());
				$PL->setUserType('escort');
				$PL->setPayment($v['net_price']);
				$PL->setRegDate(time());
				$PL->setUserId($USER->getId());
				$PL->setPaymentStatus('unpaid');
				$PL->setPeriod($v['period']);
				$PL->setLatestPeriod($v['period']);
				$PL->setDiscount($v['discount']);
				$PL->setServiceType('PRI');
				$PL->setTypeId($v['type_id']);
				$PL->setPaymentPrice($v['payment_price']);
				$PL->setNetPrice($v['net_price']);
				$PL->setDiscountPeriodPrice($v['period_discount_price']);
				$PL->setDiscountPromoPrice($v['promo_discount_price']);
				
				$PL->update();
			}
		}
		$this->action_log->insertNewAction($USER->getId(),'log_action_contract');
		
		$this->submit_payment();
		echo 'ok';
		exit();
	}
	function submit_payment(){
		//$USER = getAccountUserObject();
		//$ESCORT = $this->escort_entity->init('user_id',$USER->getId());
		
		$escortId = $this->input->post('escort_id');
		$ESCORT = $this->_ci->escort_entity->init('id',$escortId);
		$USER = $this->_ci->user_entity->init('id', $ESCORT->getUserId());
		
		//$discount_info = $this->payment_log_entity->getNetAmountOfEscort($ESCORT->getId());
		$rs = $this->db->where(array('payment_status'=>'unpaid', 'escort_id'=>$ESCORT->getId(), 'using_flag'=>'yes'))->get(TBL_ESCORT_PAYMENT_LOG)->result();
		$total = 0;
		$idArray = array();
		
		if($rs){
			$start_date = time();
			$end_date = $_SESSION['SERVICES_INFO']['PERIOD']*PERIOD_TIME + $start_date;
			foreach($rs as $item){
				$PAYLOG = $this->payment_log_entity->init('id',$item->id);
				$PAYLOG->setApplyDate( $end_date );
				//$PAYLOG->setPaymentStatus('paid');
				$PAYLOG->setLatestPaymentDate( $start_date );
				$total += $PAYLOG->getPaymentPrice();
				$PAYLOG->update();
				$idArray[] = $PAYLOG->getId();
			}
		}else{
			//echo 'ok';
			//exit();
			return true;
		}
		 
		$PAYMENT_HISTORY = $this->payment_history->createNewEntity();
		$PAYMENT_HISTORY->setEscortId($ESCORT->getId());
		$PAYMENT_HISTORY->setUserId($USER->getId());
		$PAYMENT_HISTORY->setPaymentIds(implode(',',$idArray));
		$PAYMENT_HISTORY->setTotalPrice($total);	
		$PAYMENT_HISTORY->setPromotionCode($_SESSION['SERVICES_INFO']['DISCOUNT_PROMO_CODE']);
		$PAYMENT_HISTORY->setDiscountUnit($_SESSION['SERVICES_INFO']['DISCOUNT_UNIT']);	
		$PAYMENT_HISTORY->setDiscountAmount($_SESSION['SERVICES_INFO']['DISCOUNT_AMOUNT']);	
		$PAYMENT_HISTORY->setNetAmount($_SESSION['SERVICES_INFO']['NET_AMOUNT']);			
		$PAYMENT_HISTORY->setStartDate($_SESSION['SERVICES_INFO']['STARTDATE'] = $start_date);		
		$PAYMENT_HISTORY->setEndDate($_SESSION['SERVICES_INFO']['ENDDATE'] = $end_date);		
		$PAYMENT_HISTORY->setPeriod($_SESSION['SERVICES_INFO']['PERIOD']);		
		$PAYMENT_HISTORY->setPeriodDiscountAmount($_SESSION['SERVICES_INFO']['PERIOD_DISCOUNT']);		
		$PAYMENT_HISTORY->setInfo($_SESSION['SERVICES_INFO']['DISCOUNT_PROMO_INFO']);		
		$PAYMENT_HISTORY->setPaymentStatus('unpaid');
		
		$PAYMENT_HISTORY->update();
		
		//$invoice_id = $PAYMENT_HISTORY->createNewInvoiceEscort();
		//$this->email_sender->sendEmailToUser_sendOrder($PAYMENT_HISTORY->getId(),$invoice_id);
			
	/**	foreach($rs as $item){
			$PAYLOG = $this->payment_log_entity->init('id',$item->id);
			$PAYLOG->setPaymentStatus('paid');
			$PAYLOG->update();
		}
	**/
	/**
		$subscription_id = $this->payment_log_entity->getServicesTypePaid($ESCORT->getId(), 'SUBS');
		$myPlaceListArray = $this->payment_log_entity->getServicesTypePaid($ESCORT->getId(), 'PLACE');
		$myPackListArray = $this->payment_log_entity->getServicesTypePaid($ESCORT->getId(), 'PACK');
		$myPriorityListArray = $this->payment_log_entity->getServicesTypePaid($ESCORT->getId(), 'PRI');
	**/
		
		$subscription_id = $_SESSION['SERVICES_INFO']['SUBS']['type_id'];
		
		$tempPLACE = array();
		if(isset($_SESSION['SERVICES_INFO']['PLACE'])){
			foreach($_SESSION['SERVICES_INFO']['PLACE'] as $k=>$v){
				$tempPLACE[] = $v['type_id'];
			}
		}	
		$myPlaceListArray = implode(',',$tempPLACE);
		
		$tempPACK = array();
		if(isset($_SESSION['SERVICES_INFO']['PACK'])){
			foreach($_SESSION['SERVICES_INFO']['PACK'] as $k=>$v){
				$tempPACK[] = $v['type_id'];
			}
		}	
		$myPackListArray = implode(',',$tempPACK);
		
		$tempPRI = array();
		if(isset($_SESSION['SERVICES_INFO']['PRI'])){
			foreach($_SESSION['SERVICES_INFO']['PRI'] as $k=>$v){
				$tempPRI[] = $v['type_id'];
			}
		}	
		$myPriorityListArray = implode(',',$tempPRI);
		
		$ESCORT->setSubscriptionId($subscription_id);
		$ESCORT->setPlacesListIdsContract($myPlaceListArray);
		$ESCORT->setPackageIds($myPackListArray);
		$ESCORT->setPriorityId($myPriorityListArray);
		$ESCORT->setPublished(1);
		$ESCORT->update();
		 
		/** $newPoint = 0;
		foreach(explode(',',$myPriorityListArray) as $id){
			$PRI = $this->priority_option_entity->init('id',$id);
			if($PRI){
				$newPoint += $PRI->getPriorityPercentage();
			}
		}
		$ESCORT->setPoint($newPoint + $ESCORT->getPoint());
		$ESCORT->update();
		**/
		
		//unset($_SESSION['SERVICES_INFO']);
		//echo 'ok';
		//exit();
		return true;
	}
}